<template>
  <div class="shopCartAll">
    <div class="allPrice">
      <p class="shopPrice">￥{{totalPrice}}</p>
      <p class="deliveryPrice">另需配送费3元</p>
    </div>
    <div class="shopCartIcon">
      <i class="fas fa-shopping-cart" />
    </div>
    <div class="shopBilling">
      <p>去结算</p>
    </div>
  </div>
</template>

<script>
export default {
  name:"ShopCart",
  data(){
    return{

    }
  },
  props:['cartItems'],
  methods:{
    removeFromCart(index) {
      this.$emit('remove-from-cart', index); // 仍然需要通知父组件移除商品，但总价格在子组件内计算并显示。
    }
  },
  computed: {
    totalPrice() {
      return this.cartItems.reduce((total, item) => total + item.price, 0); // 计算总价格
    }
  },

}
</script>

<style scoped>
.shopCartAll{
  position: fixed;
  bottom: 0;
  display: flex;
  width: 100%;
  height: 14vw;
}
.shopCartAll p{
  color: white;
}
.shopCartAll .allPrice{
  box-sizing: border-box;
  padding-left: 18vw;
  padding-top: 1vw;
  position: relative;
  flex: 0 0 68vw;
  background-color: #666666;
}
.allPrice .shopPrice{
  color: white;
  font-size: 4vw;
  font-weight: bold;
}
.allPrice .deliveryPrice{
  font-size: 2vw;
  color: white;
}
.shopCartAll .shopCartIcon{
  top: -4vw;
  left: 2vw;
  position: absolute;
  width: 13vw;
  height: 13vw;
  line-height: 13vw;
  text-align: center;
  font-size: 6vw;
  color: white;
  background-color: #0097FF;
  border-radius: 50%;
  border: 1.5vw solid #444444;
}
.shopCartAll .shopCartIcon p{
  position: absolute;
  right: -2vw;
  top: -2vw;
  width: 5vw;
  height: 5vw;
  line-height: 5vw;
  font-size: 3vw;
  background-color: red;
  border-radius: 50%;
}
.shopCartAll .shopBilling{
  height: 14vw;
  line-height: 14vw;
  flex: 1;
  font-weight: bold;
  text-align: center;
  background-color: #38CA73;
}
.shopCartAll .shopBilling p{
  font-size: 4.5vw;
}
</style>